﻿using System.Web.Mvc;
using doufu.Common;
using doufu.Service;

namespace doufu.WebUI
{
    [CompressAttribute]
    public class BaseController : Controller, IUser
    {
        #region ServiceFactory

        private Services _services;

        /// <summary>
        ///   Services层的Factory
        /// </summary>
        public Services Services
        {
            get { return _services ?? (_services = new Services()); }
            set { _services = value; }
        }

        #endregion

        public string Title
        {
            set { ViewBag.Title = string.Format("{0}{1}", string.IsNullOrEmpty(value) ? string.Empty : string.Format("{0} - ", value), Config.Title); }
        }

        #region IUser 成员
        public IUserIdentity user
        {
            get { return User.Identity as IUserIdentity; }
        }
        #endregion
    }
}